package com.kunyi.web.service.identity.application.controller;

import com.kunyi.web.service.identity.code.service.SegmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName test
 * @Description TODO
 * @Author zhenguo.zhuang
 * @Date 2024/7/5 17:33
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class SegmentIDTestController {

    Set<Long> setFromMap = Collections.newSetFromMap(new ConcurrentHashMap<>());

    AtomicInteger count =new  AtomicInteger(0);
    @Autowired
    private SegmentService segmentService;


    @GetMapping("/aa")
    public Long test(){
        count.incrementAndGet();
        long id = segmentService.getId("leaf-segment-test").getId();
        setFromMap.add(id);
        return id;
    }

}
